#include <stdio.h>
#define WORD_COUNT 30
#define WORD_LEN 20
int main(void)
{
    char msgs[WORD_COUNT][WORD_LEN+1], end = '\0';
    printf("Enter a sentence: ");
    int count;
    for (count = 0; count < WORD_LEN && end == '\0'; count++) {
        int ch, len = 0;
        while((ch = getchar()) != ' ') {
            if (ch == '.' || ch == '?' || ch == '!' || ch == '\n') {
                end = ch;
                break;
            }
            if (len < WORD_LEN)
                msgs[count][len++] = ch;
        }
        msgs[count][len] = '\0';
    }

    for (int i = count - 1; i >= 0; i--)
        printf("%s%c", msgs[i], i? ' ': end);
    if (end != '\n')
        printf("\n");
    return 0;
}